package com.lili.order.controller.review;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.common.result.Result;
import com.lili.model.order.entity.review.Review;
import com.lili.order.service.review.ReviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 *  用户信息管理
 */
@Api(tags = "评价管理")
@RestController
@RequestMapping("/admin/order/goodsReview")
public class ReviewController {

    @Autowired
    private ReviewService reviewService;
    @ApiOperation("评价列表")
    @PostMapping("/queryByPage")
    public Result getByPage(@RequestBody Map map){
        Page<Review> page = reviewService.queryByPage(map);
        return Result.ok(page);
    }
    @ApiOperation("发布评价")
    @PostMapping("/save")
    public Result save(@RequestBody Review review){
      int rs= reviewService.save(review);
      return  rs==1?Result.ok():Result.fail();
    }
    @ApiOperation("删除评价")
    @DeleteMapping("/delete")
    public Result delete(String id){
        int rs= reviewService.delete(id);
        return  rs==1?Result.ok():Result.fail();
    }
    @ApiOperation("修改评价")
    @PutMapping("/update")
    public  Result update(@RequestBody Review review){
        int rs= reviewService.update(review);
        return  rs==1?Result.ok():Result.fail();
    }


}
